<script type="text/javascript">

var delId;
var currentSortStr="";
var paginationPageSize =15;
var paginationTotal = <{$total}>;//记录总数
var customerId = "<{$customerId}>";//用户id

$(function(){
	$(".inventoryRow").live({
			'mouseover':function(){$(this).css('background','#FFF8DB');},
			'mouseout':function(){$(this).css('background','#FFF');}
	});
	
	$(".checkAll").click(function(){
		$(".checkProduct").attr("checked",$(".checkAll").attr("checked")=="checked"?true:false);
	});
	$(".editItem").live("click",function(){
	   //alert("/merchant/product-stocket/view-inventory-info/productId/"+$(this).attr("productid"));
		window.open("/merchant/product-stocket/view-inventory-info/productId/"+$(this).attr("productid")+"/"+new Date(),"_blank");
		//window.location.href="/merchant/product-stocket/view-inventory-info/productId/"+$(this).attr("productid");
	});
	$(".search").click(function(){
		paginationCurrentPage = 1;
		initData(0);
	});
	initData(0);
});

function loadData(page,pageSize,sortStr){
	$(".checkAll").attr("checked",false);
	if(typeof sortStr == "undefined"){
		sortStr = currentSortStr;
	}
	var product_sku = $.trim($("[name=product_sku]").val());
	
	$.ajax({ //这里使用到Jquery的ajax方法
		type: "POST",
		async: false,
		dataType: "json",
		url: "/merchant/product-stocket/inventory-list", //请求的处理url
		//data:{'page':page,'pageSize':pageSize,  'product_sku':product_sku},
		data: "page=" + page + "&product_sku="+product_sku+"&pageSize="+pageSize+sortStr,
		success: function(json) { 
			var html = '';
			paginationTotal = json.total;
			if(typeof json.ask != "undefined" && json.ask){
				if (typeof json.result == "undefined") return;
				$.each(json.result,function(k,v){
					html += '<div class="row height25 inventoryRow">';
					html += '<div style="width:150px;" class="cell editItem" title="Detail" productid="'+v.product_id+'" title="'+v.product_title+'">'+v.product_title+'</div>';
					html += '<div style="width:150px;" class="cell editItem" title="Detail" productid="'+v.product_id+'" title="'+v.product_title_cn+'">'+v.product_title_cn+'</div>';
					html += '<div style="width:150px;" class="cell" title="'+v.product_sku+'">'+v.product_sku+'</div>';
					html += '<div style="width:80px;" class="cell" title="'+v.ps_quantity+'">'+v.ps_quantity+'</div>';
					html += '<div style="width:80px;" class="cell" title="'+v.ps_quantity_hold+'">'+v.ps_quantity_hold+'</div>';
					html += '<div style="width:80px;" class="cell no-background" title="'+v.ps_last_update+'">'+v.ps_last_update+'</div>';
					html += '</div>';
				});
				
			}else{
				html = '<div class="line1" style=" text-align:center;">&nbsp;No data returns</div>';
			}
			$(".tab-div").html(html);
		}
	}); 
}
</script>
<style>
.error{
	color:red;
	margin-left:20px;
}

.width10{
	width:10%;
}

table.myTab th{ background:#f1f6f9 url(/images/left-menu-li.gif) repeat-x left top}
.myTab td{ padding:3px; border:1px solid #AECED9; text-align:center}
.myTab th{ padding:5px; border:1px solid #AECED9;}
.even-tr{background:#E6F3F9}
.hover-tr{ background:#318DAC; color:white}
.sort{cursor:pointer}
.sort:hover{color:black}

</style>
<div class="position"><a href='/default/index'><{$languages['HOME']}></a> &gt; <a href='/merchant/my-account'><{$languages['MERCHANT_CENTER']}></a>  &gt; <{$languages['OPERATION']}> &gt; <{$languages['PRODUCT_INVENTORY_LIST']}></div>

<div style="margin-top:10px">
    <div style="margin-top:15px;margin-bottom:15px;">
        SKU:
        <input class="input-width-1" type="text" name="product_sku">
        <span class="button-2 search"><{$languages.SEARCH}></span>
    </div>
</div>

<div class="inventoryClass" style="OVERFLOW-X: scroll; scrollbar-face-color:#B3DDF7;scrollbar-shadow-color:#B3DDF7;scrollbar-highlight-color:#B3DDF7;scrollbar-3dlight-color:#EBEBE4;scrollbar-darkshadow-color:#EBEBE4;scrollbar-track-color:#F4F4F0;scrollbar-arrow-color:#000000; width:658px;"">
<div class="row height25 row-header" style="width:700px; border:1px solid #cccccc">
    <div style="width:150px;" class="cell sort" sortColumn="SKU Name"><{$languages.SKUNAME}></div>
    <div style="width:150px;" class="cell sort"><{$languages.CHINESENAME}></div>
    <div style="width:150px;" class="cell sort" sortColumn="sku">SKU</div>
    <div style="width:80px;" class="cell sort" sortColumn="ps_quantity"><{$languages.QUANTITY}></div>
    <div style="width:80px;" class="cell sort" sortColumn="ps_quantity_hold"><{$languages.QUANTITYHOLD}></div>
    <div style="width:80px;" class="cell sort no-background" sortColumn="time"><{$languages.LAST_DATE}></div>
    <div class="clearFloat"></div>
</div>
    <div class="tab-div" style="width:900px;"></div>
</div>

<div class="pagination" style="padding-top:10px"></div>
<div id="tipDialog" style="display:none" title="Tip"></div>
<div id="delDialog" style="display:none" title="Product Delete Confirm">
	Are you sure to delete it?
</div>

